<?php  // -*-coding:utf-8; mode:php-mode;-*-
/**
 * @file   CtrlBase.php
 * @author koocyton <koocyton@gmail.com>
 * @date   Mon Dec 14 14:57:16 2009
 * 
 * @brief  Ctrl 的基础类
 *
 * @package       ctrl
 * @subpackage    framework.core.IController 
 */

namespace ctrl;

use framework\util;
use framework\view;
use framework\mvc\IController;
use framework\mvc\IRequestDispatcher;
use \view\RedirectView;
use \util\Functions;

/** 
 * CtrlBase Ctrl 的基础类
 *
 * @package       CtrlBase
 * @subpackage    framework.core.IController 
 */
class CtrlBase implements IController{

	/**
	 * dispatcher 对象
	 *
	 * @var object
	 * @access protected
	 */
	protected $dispatcher;

	/** 
	 * 设置 dispatcher
	 * 
	 * @param dispatcher 
	 * 
	 * @return void
	 * @access public
	 */
	public function setDispatcher(IRequestDispatcher $dispatcher)
	{
		$this->dispatcher = $dispatcher;
	}
	
	/**
	 * 获取 dispatcher
	 *
	 * @return framework\core\IRequestDispatcher
	 * @access public
	 */
	public function getDispatcher()
	{
		return $this->dispatcher;
	}

	/** 
	 * 在执行具体动作前，要执行的动作
	 * 
	 * @return ture/false
	 * @access public
	 */
	function beforeFilter()
	{
		if (empty($_SESSION['loginId']) || empty($_SESSION['loginName']))
		{
			header("Location: ?act=Login.form");
			return false;
		}
		return true;
	}

	/** 
	 * 在完成功能后，所执行的动作
	 * 
	 * @return ture/false
	 * @access public
	 */
	function afterFilter()
	{
		return true;
	}

	/** 
	 * 构造函数
	 * 
	 * @return void
	 * @access public
	 */
	public function __construct()
	{
	}
}